#include <iostream>
#include <vector>

using namespace std;


vector<vector<int>> ans;
vector<int> path;

void backtracking(vector<int>& candidates, int target, int sum, int start_index)
{
    if (sum > target)
        return;

    if (sum == target)
    {
        ans.push_back(path);
        return;
    }

    for (int i = start_index; i < candidates.size(); i++)
    {
        path.push_back(candidates[i]);
        sum += candidates[i];
        backtracking(candidates, target, sum, i);
        sum -= candidates[i];
        path.pop_back();
    }
}

int main()
{
    vector<int> candidates = { 2,3,6,7 };
    int target = 7;

    backtracking(candidates, target, 0, 0);

    return 0;
}